<%--
  Created by IntelliJ IDEA.
  User: holle
  Date: 2020/7/23
  Time: 11:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="ftm" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title></title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--引入日历插件-->
    <script type="text/javascript" src="<%=basePath%>My97DatePicker/WdatePicker.js"></script>

    <script type="text/javascript"
            src="<%=basePath%>static/js/jquery-1.12.4.min.js"></script>
    <link
            href="<%=basePath%>static/bootstrap-3.3.7-dist/css/bootstrap.min.css"
            rel="stylesheet">
    <script type="text/javascript"
            src="<%=basePath%>static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>

    <!--引入jq库-->
    <script type="text/javascript">
		$(function () {
			$(".delete").click(function () {
				var  $tr=$(this).parent().parent().parent();
				var title  =$.trim($tr.find("td:first").next().text());
				var flag = confirm("你确定要删除《"+title+"》图书的信息吗？");
				if (flag){
					return true;
				}
				return false;
			});
		})

		$(function () {
			$("#checkAll").click(function () {
				$("input").prop("checked",this.checked);
			})
		})
    </script>
</head>
<body>
<center>
    <div class="container">
        <!-- 标题 -->
        <div class="row">
            <div class="col-md-12">
                <h2>图书管理系统</h2>
                <c:if test="${sessionScope.ShoppingCart==null}">
                    <font color="red">您的购物车还空空如也!</font>
                </c:if>
            </div>
        </div>
        <br/>
        <br/>
        <form action="book/findallbook" method="post">
            图书名字： <input type="text"  name="bookname" value="${pageBean.query.bookname}"/>
            图书价格:<input type="text" name="minsal" value="${pageBean.query.minsal}"/>
            &nbsp;- -&nbsp;<input type="text" name="maxsal" value="${pageBean.query.maxsal}"/>
            <input type="submit" value="搜索">
        </form>
        <br/>
        <form action="book/deletbyid" method="post" onsubmit="return confirm('是否确认全部删除？？')">
            <!-- 显示表格数据 -->
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-hover " id="emps_table">
                        <thead>
                        <tr>
                            <td><input type="checkbox" id="checkAll">全选</td>
                            <td>书名</td>
                            <td>出版社</td>
                            <td>价格</td>
                            <td>出版日期</td>
                            <td>作者</td>
                            <td>简介</td>
                            <td>删除操作</td>
                            <td>修改操作</td>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="book" items="${bookList}">
                            <tr>
                                <td><input  type="checkbox" name="id" value="${book.bookid}"/>
                                <td><a href="book/findByid?bookid=${book.bookid}">${book.book_name}</a> </td>
                                <td>${book.public_dept}</td>
                                <td>${book.book_price}</td>
                                <td> <ftm:formatDate value="${book.public_date}" pattern="yyyy-MM-dd" /></td>
                                <td>${book.book_auth}</td>
                                <td>${fn:length(book.summary)>15?fn:substring(book.summary,0,14):book.summary}...</td>
                                <td><button class="btn btn-danger" ><a href="book/deletbyid?id=${book.bookid}"
                                                                       class="delete" class="btn btn-primary" style="color: white;text-decoration: none">删除</a></button></td>
                                <td ><button  class="btn btn-primary" >
                                    <a href="StudentServlet.do?status=edit&choise=1&id=${student.id}" style="color: white;text-decoration: none">修改</a></button> </td>
                                <td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
                <div class="row">
                    <!--分页文字信息-->.

                    <div class="col-md-6" id="page_info_area">
                        <c:url var="queryUrl" value="book/findallbook">
                            <c:param name="bookname" value="${pageBean.query.bookname}"></c:param>
                            <c:param name="minsal">
                                ${pageBean.query.minsal}
                            </c:param>
                            <c:param name="maxsal">
                                ${pageBean.query.maxsal}
                            </c:param>
                        </c:url>
                        <ul class="pagination">&nbsp;&nbsp;&nbsp;
                            <span style="font-weight: bold;line-height: 30px;text-align: center" >共${pageBean.totalPage}页&nbsp;&nbsp;&nbsp;当前第${pageBean.cp}页&nbsp;&nbsp;&nbsp;</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <c:choose>
                                <c:when test="${pageBean.cp==1}">
                                    <li class="disabled"><a href="${queryUrl}&pg=1">&laquo;</a></li>
                                </c:when>
                                <c:otherwise>
                                    <li><a href="${queryUrl}&pg=${pageBean.cp-1}">&laquo;</a></li>
                                </c:otherwise>
                            </c:choose>
                            <c:forEach begin="1" end="${pageBean.totalPage}" var="i">
                                <li><a href="${queryUrl}&pg=${i}">${i}</a></li>
                            </c:forEach>
                            <c:choose>
                                <c:when test="${pageBean.cp==pageBean.totalPage}">
                                    <li class="disabled"><a href="${queryUrl}&pg=${pageBean.totalPage}">&raquo;</a></li>
                                </c:when>
                                <c:otherwise>
                                    <li><a href="${queryUrl}&pg=${pageBean.cp+1}">&raquo;</a></li>
                                </c:otherwise>
                            </c:choose>
                        </ul>
                    </div>
                    <!--分页条信息-->
                </div>
                <!-- 按钮 -->
                <div class="row">
                    <div class="col-md-4 col-md-offset-8">
                        <c:if test="${sessionScope.ShoppingCart!=null}">
                            <button class="btn btn-primary" id="emp_add_modal_btn"><a href="cart/tocar" style="color: white;text-decoration: none">查看购物车</a></button>
                        </c:if>
                        <button class="btn btn-primary" id="emp_add_modal_btn"><a href="book/doaddpage" style="color: white;text-decoration: none">新增</a></button>
                        <button class="btn btn-danger" type="submit">全部删除</button>
                    </div>
                </div>
            </div>
        </form>
</body>
</html>

